{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[ 0,  1,  0],\n",
       "        [ 8,  0,  2],\n",
       "        [ 0,  4, -3],\n",
       "        [ 0,  0,  0]])"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import scipy.sparse as sp\n",
    "import numpy as np\n",
    "\n",
    "J = np.array([1,0,2,1,2]) # 列索引数组\n",
    "\n",
    "V = np.array([1,8,2,4,-3]) # 矩阵的元素值\n",
    "\n",
    "indptr = np.array([0, 1, 3, 5, 5])\n",
    "\n",
    "A = sp.csr_matrix((V, J, indptr), shape=(4, 3))\n",
    "\n",
    "A.todense()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
